﻿using System.Collections.Generic;
using System.Linq;
using personalplaner.common.mvvm;

namespace personalplaner.databasewizard.viewmodels.models
{
    public class LogonModel : BaseModel
    {
        IEnumerable<string> _odbcSources;
        public IEnumerable<string> OdbcSources
        {
            get
            {
                return _odbcSources;
            }
            set
            {
                _odbcSources = value;
                RaisePropertyChanged("OdbcSources");

                SelectedOdbcSource = _odbcSources.FirstOrDefault();
            }
        }

        string _selectedOdbcSource;
        public string SelectedOdbcSource
        {
            get
            {
                return _selectedOdbcSource;
            }
            set
            {
                _selectedOdbcSource = value;
                RaisePropertyChanged("SelectedOdbcSource");
            }
        }
        
        IList<string> _databases;
        public IList<string> Databases
        {
            get
            {
                return _databases;
            }
            set
            {
                _databases = value;
                RaisePropertyChanged("Databases");

                if (_databases == null)
                    SelectedDatabase = null;
                else
                    SelectedDatabase = _databases.FirstOrDefault();
            }
        }

        string _selectedDatabase;
        public string SelectedDatabase
        {
            get
            {
                return _selectedDatabase;
            }
            set
            {
                _selectedDatabase = value;
                RaisePropertyChanged("SelectedDatabase");
            }
        }

        string _user = "sa";
        public string User
        {
            get
            {
                return _user;
            }
            set
            {
                _user = value;
                RaisePropertyChanged("User");
            }
        }

        string _password = "";
        public string Password
        {
            get
            {
                return _password;
            }
            set
            {
                _password = value;
                RaisePropertyChanged("Password");
            }
        }

        bool _isNewDatabase;
        public bool IsNewDatabase
        {
            get
            {
                return _isNewDatabase;
            }
            set
            {
                _isNewDatabase = value;
                RaisePropertyChanged("IsNewDatabase");
            }
        }
    }
}
